package com.hww.bean;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.stereotype.Component;

/**
 * @Author: heweiwei
 * @Date: 4/27/25 PM5:10
 * @Description:
 */
@Component
public class LifeCycleBeanPostProcessor implements BeanPostProcessor {

    @Override
    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
        if (bean instanceof LifeCycleBean) {
            System.out.println("5. BeanPostProcessor,postProcessBeforeInitialization = " + beanName);
        }
        return bean;
    }


    @Override
    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
        if (bean instanceof LifeCycleBean) {
            System.out.println("8. BeanPostProcessor,postProcessAfterInitialization = " + beanName);
        }
        return bean;
    }
}
